package com.objectproject.main.service;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.objectproject.main.dao.MyGroupHierarchyDAOImpl;
import com.objectproject.main.model.MyGroup;
import com.objectproject.main.model.MyObject;
import com.objectproject.main.service.iface.MyGroupHierarchyService;
import com.objectproject.main.service.iface.MyObjectHierarchyService;

@Service
public class MyGroupHierarchyServiceImpl implements MyGroupHierarchyService{

	@Autowired
	MyGroupHierarchyDAOImpl myGroupHierarchyDAOImpl;

	@Override
	public void isA(MyGroup myGroup, MyGroup superGroup) {
		myGroupHierarchyDAOImpl.insertHierarchy(myGroup.getGroupId(), superGroup.getGroupId());
	}

	@Override
	public void isA(MyGroup myGroup, ArrayList<MyGroup> superGroups) {
		for(MyGroup superGroup:superGroups){
			myGroupHierarchyDAOImpl.insertHierarchy(myGroup.getGroupId(), superGroup.getGroupId());
		}
	}

	@Override
	public void isNotAnymore(MyGroup myGroup, MyGroup superGroup) {
		myGroupHierarchyDAOImpl.deleteHierarchy(myGroup.getGroupId(), superGroup.getGroupId());
	}

	@Override
	public void isNotAnymore(MyGroup myGroup, ArrayList<MyGroup> superGroups) {
		for(MyGroup superGroup:superGroups){
			myGroupHierarchyDAOImpl.deleteHierarchy(myGroup.getGroupId(), superGroup.getGroupId());
		}
	}

	
	
	
	
}
